home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: undoBtOv.C,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:56:03 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
- #include "BTREEPAGE.h"
- #include "OVPAGE.h"
- #include "BT_Log.h"
- #ifdef INIT_LRC_IS_LSN
- # include "log_globals.h"
- # include "undo_extfuncs.h"
- #endif
-
- #ifdef DEBUG
- int undoBtOvTrace = FALSE;
- #undef BT_TRACE
- #define BT_TRACE(x) { if (undoBtOvTrace) printf x; }
- #else
- #define BT_TRACE(x)
- #endif DEBUG
-
- void undoBtOv(LOGRECORDHDR* recHdr)
- {
- #ifdef INIT_LRC_IS_LSN
- LRC tempLRC;
- LRC *lrc = &tempLRC;
- #else
- TRANSREC* transRec = (TRANSREC*) Active->transRec;
- INIT_MISSING_UPDATE_INFO(transRec);
-
- LRC *lrc;
- #endif /* INIT_LRC_IS_LSN; */
-
- TRPRINT(TR_IO, TR_LEVEL_1, ("lsn:%d", recHdr->recordLSN));
-
- PID* pid = &recHdr->actionPid;
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("pid:%d", pid->page));
-
- GROUPLINK* groupLink = bf_ReadPage(UserBufGroup, pid,
- BTREE_PAGE2SIZE, BF_SEM);
- OVPAGE* op = (OVPAGE*) groupLink->bufFrame;
-
- BOOL actionDone = compareLRC( &recHdr->actionLRC, &(op->lrc())) <= 0;
-
- #ifndef INIT_LRC_IS_LSN
- ASSERT3(missingUpdateInfo != NULL);
- #endif INIT_LRC_IS_LSN
-
- RECORD_MISSING_UPDATE( actionDone, &lrc, missingUpdateInfo, pid,
- &op->lrc(), groupLink->pageHash, recHdr, PAGE_INDEX);
-
-
- if (lrc != & op->lrc()) GENERATE_LRC(lrc);
-
- LSNOFFSET undoNextLSN = recHdr->previousLSN;
-
- signalSemaphore( & groupLink->pageHash->semaphore);
-
- void* vptr = GET_LOG_IMAGE(recHdr, 0);
- PAGEHASH* pHash = actionDone ? groupLink->pageHash : 0;
-
- switch (recHdr->action) {
- case LOG_ACTION_BTOV_MODIFY_NEXT_LINK:
- {
- LogBtOvModifyNextLink* rp = (LogBtOvModifyNextLink*) vptr;
- BT_TRACE(("U: btov modify next (%d)\n", pid->page));
- if (actionDone) {
- ASSERT3(op->NextPage() == rp->newNext);
- op->NextPage() = rp->oldNext;
- }
- OV_LogModifyNextLink(op->SelfID(), pHash, *lrc,
- rp->rootPid, rp->newNext, rp->oldNext, undoNextLSN);
- }
- break;
-
- case LOG_ACTION_BTOV_MODIFY_PREV_LINK:
- {
- LogBtOvModifyPrevLink* rp = (LogBtOvModifyPrevLink*) vptr;
- BT_TRACE(("U: btov modify prev (%d)\n", pid->page));
- if (actionDone) {
- ASSERT3(op->PrevPage() == rp->newPrev);
- op->PrevPage() = rp->oldPrev;
- }
- OV_LogModifyPrevLink(op->SelfID(), pHash, *lrc,
- rp->rootPid, rp->newPrev, rp->oldPrev, undoNextLSN);
- }
- break;
-
- case LOG_ACTION_BTOV_INSERT:
- {
- LogBtOvInsert* rp = (LogBtOvInsert*) vptr;
- BT_TRACE(("U: btov insert (%d)\n", pid->page));
- ASSERT3(rp->numSlots > 0);
- ASSERT3(rp->startSlot >= 0);
-
- OV_LogDelete(op->SelfID(), pHash, *lrc,
- rp->rootPid, rp->elSize,
- rp->startSlot, rp->numSlots, rp->data, undoNextLSN);
- if (actionDone)
- op->Remove(rp->startSlot, rp->numSlots);
- }
- break;
-
- case LOG_ACTION_BTOV_DELETE:
- {
- LogBtOvDelete* rp = (LogBtOvDelete*) vptr;
- BT_TRACE(("U: btov delete (%d)\n", pid->page));
-
- ASSERT3(rp->numSlots > 0);
- ASSERT3(rp->startSlot >= 0);
-
- if (actionDone)
- op->Insert(rp->startSlot, rp->numSlots, rp->data);
-
- OV_LogInsert(op->SelfID(), pHash, *lrc,
- rp->rootPid, rp->elSize,
- rp->startSlot, rp->numSlots, rp->data, undoNextLSN);
- }
- break;
-
- default:
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
- #ifdef BT_DEBUG
- switch (recHdr->action) {
- case LOG_ACTION_BTOV_MODIFY_NEXT_LINK:
- case LOG_ACTION_BTOV_MODIFY_PREV_LINK:
- ASSERT3(op->CheckPage());
- break;
-
- case LOG_ACTION_BTOV_INSERT:
- case LOG_ACTION_BTOV_DELETE:
- ASSERT3(op->CheckPage());
- break;
- }
- #endif /* BT_DEBUG */
-
- bf_UnfixPage(groupLink, BF_DEFAULT, actionDone);
- }
-